package com.example.wendao.view.viewholder;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.navigation.NavDirections;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;

import com.example.wendao.R;
import com.example.wendao.common.PageUtils;
import com.example.wendao.common.ViewHolderBind;
import com.example.wendao.model.entity.User;

public class JumpToDetailTestViewHolder extends RecyclerView.ViewHolder implements ViewHolderBind<User> {

    private TextView tvUserTest;

    public JumpToDetailTestViewHolder(@NonNull ViewGroup viewGroup) {
        super(PageUtils.inflateItemView(viewGroup, R.layout.item_user_test));
        tvUserTest = itemView.findViewById(R.id.tv_user_test);
    }

    @Override
    public void bindTo(User user) {
        tvUserTest.setText("我是用户：" + user.getUserId());
        itemView.setOnClickListener(v -> {
            Toast.makeText(itemView.getContext(), "我被点击了", Toast.LENGTH_SHORT).show();
            Bundle bundle = new Bundle();
            bundle.putInt("userId", 1);
            Navigation.findNavController(v).navigate(R.id.plant_detail_fragment, bundle);
        });
    }
}


